#-*- coding:utf-8 -*-

import paramiko
 
transport = paramiko.Transport(('localhost', 22))
transport.connect(username='lxl', password='8901')
 
sftp = paramiko.SFTPClient.from_transport(transport)   #如果连接需要密钥，则要加上一个参数，hostkey="密钥"
 
sftp.put('long.txt', '/home/lxl/long.txt')           #将本地的Windows.txt文件上传至服务器/root/Windows.txt
 
transport.close()#关闭连接